package com.example.forum.mapper;

import com.example.forum.entity.Board;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

/**
 * @author lyk19
 * @description 针对表【t_board】的数据库操作Mapper
 * @createDate 2024-08-01 12:54:53
 * @Entity generator.domain.TBoard
 */

@Mapper
public interface BoardMapper {

    /**
     * 获取板块列表
     *
     * @param boardSize
     * @return
     */
    List<Board> getList(Integer boardSize);

    /**
     * 根据板块id获取板块信息
     *
     * @param boardId
     * @return
     */
    @Select("select * from t_board where id = #{boardId}")
    Board getById(Long boardId);

    /**
     * 根据板块id更新板块信息
     *
     * @param boardId
     */
    @Update("update t_board set articlecount = articlecount + 1 where id = #{boardId}")
    Integer updateArticleCount(Long boardId);

    /**
     * 获取板块id列表
     *
     * @return
     */
    @Select("select id from t_board")
    List<Long> getIds();

    /**
     * 根据板块id删除文章
     *
     * @param id
     */
    @Update("update t_board set articlecount = articlecount - 1 where id = #{id}")
    Integer deleteArticleCount(Long id);
}




